import { BasicColumn, FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import imgBase64 from '/@/views/demo/feat/download/imgBase64';

export const columns: BasicColumn[] = [
  {
    title: '公众号名称',
    dataIndex: 'name',
    width: 200,
    align: 'left',
  },
  {
    title: '图片',
    dataIndex: 'photoUrl',
    width: 80,
    slots: { customRender: 'img' },
    // customRender: ({ text }) => {
    //   return render.renderImage(text);
    // },
  },
  {
    title: '应用ID',
    dataIndex: 'appid',
    width: 180,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    sorter: true,
    width: 180,
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 100,
    customRender: ({ text }) => {
      return text == '1' ? '正常' : '冻结';
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'name',
    label: '公众号名称',
    component: 'JInput',
    colProps: { span: 8 },
  },
  {
    field: 'appid',
    label: '应用ID',
    component: 'JInput',
    colProps: { span: 8 },
  },
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    componentProps: {
      options: [
        { label: '正常', value: 1 },
        { label: '冻结', value: 0 },
      ],
    },
    colProps: { span: 8 },
  },
  {
    field: 'fieldTime',
    component: 'RangePicker',
    label: '时间字段',
    colProps: {
      span: 8,
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    field: 'name',
    label: '名称',
    component: 'Input',
    required: true,
  },
  {
    label: '图片',
    field: 'photoUrl',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 1,
    },
    required: true,
  },
  {
    field: 'appid',
    label: '应用ID',
    component: 'Input',
    required: true,
  },
  {
    field: 'secret',
    label: '秘钥',
    component: 'Input',
    required: true,
  },
  {
    field: 'token',
    label: '令牌',
    component: 'Input',
    required: true,
  },
  {
    field: 'aesKey',
    label: '消息体加解密密钥',
    component: 'Input',
    required: true,
  },
  {
    field: 'status',
    label: '状态',
    component: 'RadioButtonGroup',
    defaultValue: 1,
    componentProps: {
      options: [
        { label: '正常', value: 1 },
        { label: '冻结', value: 0 },
      ],
    },
  },
];
